const mongoose = require('mongoose')

const { Schema, model } = mongoose

const commentsSchema = new Schema(
  {
    __v: {
      type: Number,
      select: false
    },
    content: {
      type: String,
      required: true
    },
    commentator: {
      type: Schema.Types.ObjectId,
      ref: 'User',
      required: true,
      select: false
    },
    question_id: {
      type: String,
      required: true,
      select: true
    },
    answer_id: {
      type: String,
      required: true,
      select: true
    },
    root_comment_id: {
      type: String
    },
    replay_to: {
      type: Schema.Types.ObjectId,
      ref: 'User'
    }
  },
  { timestamps: true }
)

module.exports = model('Comment', commentsSchema)
